//这里书写属性相关的API文件
import request from "@/utils/request";
import type { CategoryResponseData, AttrResponseData } from "./type";
//属性管理模块接口地址
enum API {
    //获取一级分类接口地址
    C1_URL = '/admin/product/getCategory1',
    //获取二级分类接口地址
    C2_URL = '/admin/product/getCategory2/',
    //获取三级分类接口地址
    C3_URL = '/admin/product/getCategory3/',
    //获取分类下已有的属性与属性值
    ATTR_URL = '/admin/product/attrInfoList/',
    //添加或者修改已有的属性的接口
    ADDORUPDATEATTR_URL = '/admin/product/saveAttrInfo',
    //删除某一个已有的属性
    DELETEATTR_URL = '/admin/product/deleteAttr/'
}

//获取一级分类的接口方法
export function reqC1() {
    return request<any, CategoryResponseData>({
        url: API.C1_URL,
        method: 'get'
    })
}

//获取二级分类的接口方法
export function reqC2(category1Id: number | String) {
    return request<any, CategoryResponseData>({
        url: API.C2_URL + category1Id,
        method: 'get'
    })
}
//获取三级分类的接口方法
export function reqC3(category2Id: number | String) {
    return request<any, CategoryResponseData>({
        url: API.C3_URL + category2Id,
        method: 'get'
    })
}
// 获取分类下已有的属性与属性值
export function reqAttrInfoList(category1Id: number | String, category2Id: number | String, category3Id: number | String) {
    return request<any, AttrResponseData>({
        url: API.ATTR_URL + category1Id + '/' + category2Id + '/' + category3Id,
        method: 'get'
    })

}